﻿using System;
using System.Text;
using Asistente.Model.General;
using Asistente.Model.IFPUG.MeasureUtilities;

namespace Asistente.Model.IFPUG
{
    //Representa una funcion de datos de IFPUG, ILF o EIF
    public class DataFunction : IMeasurable
    {
        public int Det { get; set; }
        public int Ret { get; set; }
        public DataFunctionType Type { get; set; }
        
        //Se mide la funcion de datos segun su tipo
        public int Measure()
        {
            switch (Type)
            {
                case DataFunctionType.Eif:
                    return IfpugMeasureManager.Instance.EifMeasure(Det, Ret);
                case DataFunctionType.Ilf:
                    return IfpugMeasureManager.Instance.IlfMeasure(Det, Ret);
                default: throw new NotImplementedException(); // No hay otro tipo
            }
        }

        public override string ToString()
        {
            var content = new StringBuilder();
            content.Append("<td>");
            content.Append(Type.ToString().ToUpper());
            content.Append("</td>");
            content.Append("<td>");
            content.Append(Det);
            content.Append("</td>");
            content.Append("<td>");
            content.Append(Ret);
            content.Append("</td>");
            return content.ToString();
        }

        internal string ToHtml()
        {
            var content = new StringBuilder();
            content.Append("\t" + Type.ToString().ToUpper());
            content.Append("\t" + Det);
            content.Append("\t" + Ret);
            return content.ToString();
        }
    }
}
